package com.example.trabajofinal.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;

import com.example.trabajofinal.R;
import com.example.trabajofinal.backend.CursosManager;

public class SplashActivity extends Activity
{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash_activity);

		new BajarCursosAsync().execute();

	}



	class BajarCursosAsync extends AsyncTask<Void, Void, Void> {

		@Override
		protected Void doInBackground(Void... params) {

			if(CursosManager.getInstance().getCursos() == null){
				CursosManager.getInstance().downloadCursos();
			}

			return null;
		}

		@Override
		protected void onPostExecute(Void result) {
			super.onPostExecute(result);

			Intent i = new Intent(SplashActivity.this, LoginActivity.class);
			startActivity(i);

			// close this activity
			finish();
		}

	}

}
